package com.cskaoyan.shopping.converter;


import com.cskaoyan.shopping.dal.entitys.Panel;
import com.cskaoyan.shopping.dal.entitys.PanelContentItem;
import com.cskaoyan.shopping.dto.PanelContentItemDto;
import com.cskaoyan.shopping.dto.PanelDto;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

@Component
public class PanelPanelDtoConverter {


    public static PanelDto item2Dto(Panel panel){
        PanelDto panelDto=new PanelDto();
        panelDto.setId(panel.getId());
        panelDto.setLimitNum(panel.getLimitNum());
        panelDto.setName(panel.getName());
        panelDto.setPosition(panel.getPosition());
        panelDto.setRemark(panel.getRemark());
        panelDto.setStatus(panel.getStatus());
        panelDto.setType(panel.getType());
        panelDto.setSortOrder(panel.getSortOrder());

        List<PanelContentItem> panelContentItems = panel.getPanelContentItems();

        List<PanelContentItemDto> panelContentItems1 = new ArrayList<>();

        for (PanelContentItem panelContentItem:panelContentItems
             ) {
            PanelContentItemDto panelContentItemDto = item2Dto1(panelContentItem);
            panelContentItems1.add(panelContentItemDto);
        }

         panelDto.setPanelContentItems(panelContentItems1);
        return panelDto;
    }


    private static PanelContentItemDto item2Dto1(PanelContentItem panelContentItem) {
        PanelContentItemDto panelContentItemDto = new PanelContentItemDto();

        panelContentItemDto.setCreated(panelContentItem.getCreated());
        panelContentItemDto.setFullUrl(panelContentItem.getFullUrl());
        panelContentItemDto.setId(panelContentItem.getId());
        panelContentItemDto.setId(panelContentItem.getId());
        panelContentItemDto.setPicUrl(panelContentItem.getPicUrl());
        panelContentItemDto.setPicUrl2(panelContentItem.getPicUrl2());
        panelContentItemDto.setPicUrl3(panelContentItem.getPicUrl3());
        panelContentItemDto.setProductId(panelContentItem.getProductId());
        panelContentItemDto.setProductName(panelContentItem.getProductName());
        panelContentItemDto.setPanelId(panelContentItem.getPanelId());
        panelContentItemDto.setSalePrice(panelContentItem.getSalePrice());
        panelContentItemDto.setSortOrder(panelContentItem.getSortOrder());
        panelContentItemDto.setSubTitle(panelContentItem.getSubTitle());
        panelContentItemDto.setType(panelContentItem.getType());
        panelContentItemDto.setUpdated(panelContentItem.getUpdated());


        return panelContentItemDto;
    }
    }

